﻿using System;
namespace Producers.Taitis.Xtee.Riik.Ee.Producer.Taitis {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="noue_jada_item", Namespace="http://producers.taitis.xtee.riik.ee/producer/taitis", Target=typeof(NoueJadaItem))]
    public class NoueJadaItemSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected INoueJadaItem clazz;
        
        public NoueJadaItemSerializer(INoueJadaItem clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("noude_sisu");
            if (clazz.NoudeSisu!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.NoudeSisu))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : NoudeSisu");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("noude_suurus");
            if (clazz.NoudeSuurus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.NoudeSuurus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : NoudeSuurus");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "noude_sisu")) {
                goto noude_sisu;
            }
            else {
                if ((Reader.LocalName == "noude_suurus")) {
                    goto noude_suurus;
                }
                else {
                    return;
                }
            }
        noude_sisu:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>noue_jada_item>noude_sisu");
            }
            clazz.NoudeSisu = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("noude_sisu")).Value;
            goto START;
        noude_suurus:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>noue_jada_item>noude_suurus");
            }
            clazz.NoudeSuurus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("noude_suurus")).Value;
            goto START;
        }
    }
}
